package com.gisocn.onemap.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.ProgressBar;
import androidx.exifinterface.media.ExifInterface;
import com.gisocn.onemap.sgzx.R;

/* loaded from: classes2.dex */
public class MyProgress extends ProgressBar {
    Paint mPaint;
    String text;

    public MyProgress(Context context) {
        super(context);
        System.out.println("1");
        initText();
    }

    public MyProgress(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        System.out.println("2");
        initText();
    }

    public MyProgress(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        System.out.println(ExifInterface.GPS_MEASUREMENT_3D);
        initText();
    }

    @Override // android.widget.ProgressBar
    public synchronized void setProgress(int i) {
        setText(i);
        super.setProgress(i);
    }

    @Override // android.widget.ProgressBar, android.view.View
    protected synchronized void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Rect rect = new Rect();
        Paint paint = this.mPaint;
        String str = this.text;
        paint.getTextBounds(str, 0, str.length(), rect);
        canvas.drawText(this.text, (getWidth() / 2) - rect.centerX(), (getHeight() / 2) - rect.centerY(), this.mPaint);
    }

    private void initText() {
        Paint paint = new Paint();
        this.mPaint = paint;
        paint.setTextSize(getResources().getDimensionPixelOffset(R.dimen.sp_18));
        this.mPaint.setColor(-16777216);
    }

    private void setText() {
        setText(getProgress());
    }

    private void setText(int i) {
        int max = (i * 100) / getMax();
        this.text = String.valueOf(max) + "%";
    }
}
